package 蓝桥真题;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class 子串分值 {
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    final static int N=100030;
    static char[]str=new char[N];
    public static void main(String[]args)throws Exception{
        br.read(str);
        long res=0L;
        for(int i=0;str[i]!='\n';i++){
        	int l=0,r=0;
        	int t=i-1;
        	while(t>=0&&str[t]!=str[i]){
        		l++;
        		t--;
        	}
        	t=i+1;
        	while(str[t]!='\n'&&str[t]!=str[i]){
        		r++;
        		t++;
        	}
        	res+=(l+1)*(r+1);
        }
        System.out.print(res);
    }

}
